﻿using System;

namespace CommonModel
{
    [Serializable]
    public class BaseModel
    {
        public string Id { get; set; }

        /// <summary>
        /// 保证Id不为空
        /// 若为空，则生成一个Id
        /// </summary>
        public void EnsureIdNotNull()
        {
            if (string.IsNullOrWhiteSpace(this.Id))
            {
                this.Id = System.Guid.NewGuid().ToString();
            }
        }
    }
}
